<?php

namespace app\helper\ChannelSdk;

use app\atrait\Single;
use Exception;

class Quick
{

    use Single;


    public function loginAuth($uid, $token): array
    {

        $url = 'https://checkuser.quickapi.net/v2/checkUserInfo?uid=' . $uid . '&token=' . $token;

        try {
            $res = (int)file_get_contents($url) ?? 0;
        } catch (Exception $e) {
            return [
                'state' => false,
                'message' => $e->getMessage(),
            ];
        }

        return [
            'state' => $res === 1,
            'message' => $res === 1 ? '' : '登录失败',
            'data' => $res === 1 ? [
                'uid' => $uid,
                'account' => null,
                'age' => null,
            ] : [],
        ];

    }

}